home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <exec/exec.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include "work:romconf/doorheader.h"
- #define RIGHTARROW 2
- #define LEFTARROW 3
- #define UPARROW 4
- #define DOWNARROW 5
- #define gu getuserstring
- char cmd[100];
- char im[200][82];
- int x,y,line;
- void end();
- void showstat(int line,int x,int y);
- void InitArray();
- void SaveAs();
- void showarg(char *str[]);
- void makearg(char *str);
- void sr(char *str);
- void LoadForm(char *str);
- void Goto(int x,int y);
- int node;
- #define sm sendmessage
- #define cm sendchar
- #define pu putuserstring
- #define co ConOnly
- char *argment[50];
- int argcount=0;
- struct FORM
- {
- short x,y;
- } Fm[100];
- int LastForm=0;
- int CurrForm=0;
- main(int argc,char *argv[])
- {
- char hmd;
- BOOL stop=FALSE;
- int tline=0,i;
- x=y=line=0;
-
- if(argc!=2)
- {
- printf("FullEdit v1.0 written by Joseph Hodge\n");
- printf("This is an XIM for AmiExpress v2.0+\n");
- printf("\n");
- exit(0);
- }
- Register(argv[1][0]-'0');
- node = argv[1][0]-'0';
- pu(NULL,RAWARROW);
- InitArray();
- sm("",0);
-
- sm("FullEdit version 1.0 written by Joseph Hodge",1);
- sm("------------------------------------------------------------------------------",1);
-
- sm("1H",0);
- sm("",0);
-
- sm("------------------------------------------------------------------------------",1);
- sm("Press '/' at the begining of any line to exit editor.",1);
- sm("------------------------------------------------------------------------------",0);
- co(" p",0);showstat(line,x,y); co(" p",0);
- gu(cmd,BB_MAINLINE);
- makearg(cmd);
-
- if(argcount==2)
- {
- LoadForm(argment[1]);
- }
- Goto(Fm[CurrForm].x+1,Fm[CurrForm].y); x=Fm[CurrForm].x;
- y=Fm[CurrForm].y;
- do
- {
- hmd=Fhotkey();
- switch(hmd)
- {
- case LEFTARROW: x +=1; if(x>79) x=79; else sm("C",0); break;
- case RIGHTARROW:x -=1; if(x<0) x=0; else sm("D",0); break;
- case UPARROW: y -=1; if(y<0) y=0; else { sm("A",0); tline--; }break;
- case DOWNARROW: y +=1; if(y>16) y=16; else{ sm("B",0); tline++;
- if(tline>line) line++;} break;
- case 12:
- case 13:
- CurrForm +=1; if(CurrForm>=LastForm) CurrForm=0;
- y=Fm[CurrForm].y; x=Fm[CurrForm].x; Goto(x,y);
- /*y +=1; x=0; if(y>16) y=16; else { tline++;if(tline>line)line++;}
- */ break;
- case '\b':
- x = x-1; if(x<0) x=0; else sm("\b \b",0); break;
- default: if(hmd=='/' && x==0) { stop=TRUE; break;} cm(hmd,0); im[y][x]=hmd; x +=1; if(x>79)x=79;
-
- }
- co(" p",0);showstat(line,x,y); co(" p",0);
- }while(!stop);
-
- SaveAs();
- sm("",0);
- sm("",1);
- sm("Exiting FullEdit",1);
- sm("",1);
- ShutDown();
- end();
- }
- void InitArray()
- {
- register int i,j;
- for(i=0;i<200;i++)
- {
- for(j=0;j<79;j++)
- im[i][j]=' '; im[i][j]='\0';
- }
- }
- void showstat(int line,int x,int y)
- {
- char str[200];
- /* sm("",0);
- sm("H",0);
-
-
- sprintf(str,"--%3d--%2d--%2d--------------------------------------------------------------",line,x,y);
- sm(str,1);
- */
- sprintf(str,"%d;%dH",y+3,x+1);
- sm(str,0);
- }
- void SaveAs()
- {
- FILE *fi;
- char FileName[80];
- register int i;
- gu(cmd,BB_LOCAL);
- sprintf(FileName,"%sNode%d/Work/msg",cmd,node);
- fi=fopen(FileName,"w");
- if(fi==NULL)
- {
- sm("Error, cannot locate node(x)/work",1);
- return;
- }
- i=0;
- while(i<line)
- {
- fprintf(fi,"%s\n",im[i]);
- i++;
- }
- fclose(fi);
- }
- void end()
- {
- exit(0);
- }
- void showarg(char *str[])
- {
- register int i=0;
- while(str[i][0]!=NULL)
- {
- strcpy(cmd,str[i]);
- sm(cmd,1);
- i++;
- }
- }
- void makearg(char *str)
- {
- static int i=0;
- static int j=0;
- argcount=0;
- while(1)
- {
- argment[j]=str+i; j++; argment[j]=NULL; argcount++;
- if(*(str+i)=='\0') { argment[j]=NULL; return; }
- while(*(str+i)>32)
- {
- i++;
- }
- if(*(str+i)=='\0') return;
- *(str+i)='\0';i++;
- }
- }
-
- void LoadForm(char *str)
- {
- FILE *fi;
- char local[100];
- register int i=0,j;
- fi=fopen(str,"r");
- if(fi==NULL) return;
- while(fgets(cmd,80,fi)!=NULL && i<15)
- {
-
- j=0;
- sprintf(local,"%d;%dH",i+3,1);
- sm(local,0);
- sr(cmd);
- while(cmd[j]!='\0' && j<79)
- {
- im[i][j]=cmd[j]; if(cmd[j]=='[') { Fm[LastForm].x=j+1;
- Fm[LastForm].y=i; LastForm++; }
- j++;
- }
- sm(cmd,0);
- i++; line++;
- }
- fclose(fi);
- }
-
- void sr(char *str)
- {
- register int i;
- i=strlen(str)-1;
- while(i>-1)
- {
- if(*(str+i)<=32) *(str+i)='\0'; else break;
- i--;
- }
- }
-
- void Goto(int x,int y)
- {
- char local[20];
- sprintf(local,"%d;%dH",y+3,x);
- sm(local,0);
- }
-